﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using WebSite.Common.Interfaces.Repositories;
using WebSite.Common.Models.ViewModels;
using WebSite.Common.Utils;
using WebSite.DAL.Db.Repositories;

namespace WebSite.Controllers
{
    public class StudentController : Controller
    {
        private ILayoutRepository _layoutRepo;
        private ICourseRepository _courseRepo;

        public StudentController(ILayoutRepository layoutRepo,ICourseRepository courseRepo)
        {
            _layoutRepo = layoutRepo;
            _courseRepo = courseRepo;
        }

        public StudentController()
            : this(new DbLayoutRepository("DbСontext"), new DbCourseRepository("DbСontext"))
        {

        }

        //
        // GET: /Student/

        public ActionResult Index()
        {
            PageLayoutVM layout = _layoutRepo.LoadLayout("student");
            PageLayoutVM galleryLayout = _layoutRepo.LoadLayout("gallery");

            Tuple<PageLayoutVM, PageLayoutVM> layouts = new Tuple<PageLayoutVM, PageLayoutVM>(layout, galleryLayout);

            return View(layouts);
        }

        public ActionResult feedbacks(int id)
        {
           IPagedResult<FeedbackVM> result = _courseRepo.LoadFeedbacks(PagedRequest.Everything(), id == -1 ? (int?)null : id);

            return Json(result,JsonRequestBehavior.AllowGet);
        }
    }
}
